Skip to content

fix(convert): MITgcm netCDF C-grid xgcm axes and coords for #2484#2555

Closed
amit221 wants to merge 2 commits intoParcels-code:mainfrom
amit221:fix/issue-2484
Closed

fix(convert): MITgcm netCDF C-grid xgcm axes and coords for #2484#2555
amit221 wants to merge 2 commits intoParcels-code:mainfrom
amit221:fix/issue-2484

Conversation

@amit221
Copy link

@amit221 amit221 commented Mar 24, 2026

Summary

This fixes convert.mitgcm_to_sgrid for MITgcm netCDF circulation-model data where velocity fields use C-grid staggered dimensions Xp1 / Yp1 (instead of XC / YC). Previously, FieldSet.from_sgrid_conventions failed with ValueError: Dimension "Xp1" has no axis attribute because those dims were not wired to the xgcm X/Y axes after conversion.

Changes:

  • Emit SGRID face_dimensions that map Xp1 / Yp1 onto the xgcm X/Y axes when present (with LOW padding so lon / lat stay on the non-center positions expected by XGrid). Fall back to the existing XC / YC + HIGH padding behavior when Xp1 / Yp1 are absent.
  • Accept either Zl or depth in the coords subset (for workflows that rename cell-center Z to depth); map depth to axis Z in _MITGCM_AXIS_VARNAMES.
  • Run _maybe_convert_time_from_float_to_timedelta for MITgcm output, consistent with croco_to_sgrid.
  • Add regression test test_convert_mitgcm_netcdf_circulation_model_to_fieldset mirroring the issue snippet.

How to test

From the repo root, with the test pixi environment (see contributing docs):

pixi run -e test tests -- tests/test_convert.py::test_convert_mitgcm_netcdf_circulation_model_to_fieldset

Optionally run the full convert tests:

pixi run -e test tests -- tests/test_convert.py

Fixes #2484

…ode#2484

- Emit SGRID face_dimensions that map Xp1/Yp1 onto the xgcm X/Y axes when
  present (LOW padding keeps lon/lat on non-center positions for XGrid).
- Accept Zl or depth in coords; set axis Z on depth when used.
- Convert float model time to timedelta like croco_to_sgrid.

Co-authored-by: Claude <noreply@anthropic.com>
@VeckoTheGecko
Copy link
Contributor

VeckoTheGecko commented Mar 25, 2026

Hi @amit221 . Thanks for submitting a PR and for your interest in our project. I can't really make sense of your PR though, and given claude is a co-author on the commit I think that this is an autogenerated PR. Please be careful to follow our AI policy when submitting contributions. For this problem in particular (and in general when working in the convert.py module) knowledge about the underlying Ocean General Circulation Models and their outputs is very important - we would prefer users that have experience with these models contribute here as LLMs can easily hallucinate details.

I'm closing this. Let me know if you'd like to contribute to other areas.

@github-project-automation github-project-automation bot moved this from Backlog to Done in Parcels development Mar 25, 2026
@amit221 amit221 deleted the fix/issue-2484 branch March 25, 2026 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

convert.mitgcm_to_sgrid breaks on datasets_circulation_models["ds_MITgcm_netcdf"]

2 participants